<?php
/**
 * 后台首页控制器
 * @author yupoxiong<i@yufuping.com>
 */

namespace app\admin\controller;

use app\admin\model\AdminLog;
use app\admin\model\AdminMenu;
use app\admin\model\AdminRole;
use app\admin\model\AdminUser;
use tools\SystemInfo;
use think\Request;
use think\Db;

class IndexController extends Controller
{
    public function index(Request $request)
    {

        
       //更新时间
        $time = date('Y-m-d H:i:s', time());
        // 今天新增会员数量
        $add_user_today = Db::name('user')
            ->whereTime('create_time', 'today')
            ->count();
        //昨天
        $add_user_yesterday = Db::name('user')
            ->whereTime('create_time', 'yesterday')
            ->count();
        //总
        $user_all = Db::name('user')
            ->count();
        //变化
        $add_change = $add_user_today - $add_user_yesterday;
        if ($add_change >= 0) {
            $add_change = '+' . $add_change;
        }
        $date=[
            'time' => $time,
            'add_user_today' => $add_user_today,
            'add_user_yesterday' => $add_user_yesterday,
            'add_user_change' => $add_change,
            'user_all' => $user_all,
        ];
        $this->assign([
            'res'=>$date,
        ]);
        return $this->fetch();
    }


}
